/**   
 * 项目名：化工企业安全生产信息化管理平台
 * 日期：    2020-03-17 14:00:30  
 * Copyright (c) 2015- -版权所有     
 */

package com.joysuch.wwyt.edu.entity;

import static javax.persistence.GenerationType.IDENTITY;
import java.util.Set;
import java.util.LinkedHashSet;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.EntityListeners;

import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;

import lombok.Data;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@EntityListeners({ AuditingEntityListener.class, AutoSetCommonFieldListener.class })
@Entity
@Table(name = "wwyt_edu_course_study_history")
@SQLDelete(sql="update wwyt_edu_course_study_history set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql="update wwyt_edu_course_study_history set DELETE_FLAG = '1' where id= ?")
@Where(clause="DELETE_FLAG = '0'")
@Data
public class EduCourseStudyHistory implements java.io.Serializable{
    
    //columns START
     @Id
    @GeneratedValue(strategy = IDENTITY)
    
    //ID
    @Column(name = "ID", unique = true, nullable = false)
    private Long id;
    
    //用户ID
    @Column(name = "USER_ID")
    private Long userId;
    
    //课程ID
    @Column(name = "COURSE_ID")
    private Long courseId;
    
    //课件ID
    @Column(name = "COURSEWARE_ID")
    private Long coursewareId;
    
    //课件类型
    @Column(name = "COURSEWARE_TYPE", length = 1)
    private String coursewareType;
    
    //开始时间
    @Column(name = "START_TIME")
    private java.util.Date startTime;
    
    //时长（分钟）
    @Column(name = "LENGTH_MINUTE")
    private Byte lengthMinute;
    
    //当前位置
    @Column(name = "CURRENT_PROGRESS")
    private Integer currentProgress;
    
    //当前进度百分比
    @Column(name = "CURRENT_PROGRESS_RATIO")
    private Byte currentProgressRatio;
    
    //绝对内容长度
    @Column(name = "STUDY_CONTENT_LENGTH")
    private Integer studyContentLength;
    
    //创建人
    @org.springframework.data.annotation.CreatedBy
    @Column(name = "CREATE_BY")
    private Long createBy;
    
    //创建时间
    @org.springframework.data.annotation.CreatedDate
    @Column(name = "CREATE_TIME")
    private java.util.Date createTime;
    
    //更新人
    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    private Long updateBy;
    
    //更新时间
    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME")
    private java.util.Date updateTime;
    
    //删除标记
    @Column(name = "DELETE_FLAG", length = 2)
    private String deleteFlag;
    
    //组织机构代码
    @Column(name = "ORG_CODE", length = 100)
    private String orgCode;
    
    //租户
    @Column(name = "TENENT_ID")
    private Long tenentId;
    //columns END

    public int hashCode() {
        return new HashCodeBuilder()
            .append(getId())
            .toHashCode();
    }
    
    public boolean equals(Object obj) {
        if(obj instanceof EduCourseStudyHistory == false) return false;
        if(this == obj) return true;
        EduCourseStudyHistory other = (EduCourseStudyHistory)obj;
        return new EqualsBuilder()
            .append(getId(),other.getId())
            .isEquals();
    }
}

